<!-- 抽奖设置 -->
<div class="search">
  <nz-select style="width:100px;margin-right: 5px;" [(ngModel)]="status" nzAllowClear nzPlaceHolder="使用状态"
    (ngModelChange)="searchData()">
    <nz-option *ngFor="let item of statuslist" [nzValue]="item.key" [nzLabel]="item.value"></nz-option>
  </nz-select>
  <nz-input-group nzSuffixIcon="anticon anticon-search" style="width:75%;margin-left:1rem;">
    <input type="text" nz-input placeholder="输入名称查询" [(ngModel)]="title" (keyup.enter)="searchData()">
  </nz-input-group>
  <a (click)="searchData()">查询</a>
  <a (click)="add()">添加</a>
</div>

<nz-table #ajaxTable nzShowSizeChanger [nzFrontPagination]="false" [nzData]="dataSet" [nzLoading]="loading" [nzTotal]="total"
  [nzShowTotal]="totalTemplate" [(nzPageIndex)]="pageIndex" [(nzPageSize)]="pageSize" (nzPageIndexChange)="searchData()"
  (nzPageSizeChange)="searchData(true)" [nzScroll]="{ x:'900px',y: '400px' }">
  <thead>
    <tr>
      <th nzWidth="60px" nzLeft="0px">序号</th>
      <th nzWidth="80px">活动头标题</th>
      <th nzWidth="80px">活动标题</th>
      <th nzWidth="80px">使用状态</th>
      <th nzWidth="80px">活动时间</th>
      <th nzWidth="80px">活动规则</th>
      <th nzWidth="80px">抽奖次数</th>
      <th nzWidth="80px">活动开始日期</th>
      <th nzWidth="80px">活动结束日期</th>
      <th nzWidth="100px">创建人</th>
      <th nzWidth="100px">更新时间</th>
      <th nzWidth="80px" nzRight="0px">操作</th>
    </tr>
  </thead>
  <tbody>
    <tr *ngFor="let data of ajaxTable.data;index as i">
      <td nzLeft="0px">{{i+1}}</td>
      <td>{{data.headtitle}}</td>
      <td>{{data.title}}</td>
      <td>{{data.status}}</td>
      <td>{{data.gametime}}</td>
      <td>{{data.gamerule}}</td>
      <td>{{data.count}}</td>
      <td>{{data.starttime | date:"yyyy-MM-dd"}}</td>
      <td>{{data.endtime | date:"yyyy-MM-dd"}}</td>
      <td>{{data.createuser}}</td>
      <td>{{data.updateTime | date:"yyyy-MM-dd HH:mm"}}</td>

      <td nzRight="0px">
        <a *ngIf="data.status=='有效'" (click)="lock(data._id)">禁用</a>
        <a *ngIf="data.status!='有效'" (click)="open(data._id)">启用</a>
        <a (click)="edit(data._id)">编辑</a>
      </td>
    </tr>
  </tbody>
</nz-table>

<ng-template #totalTemplate let-total>
  共 {{total}} 条
</ng-template>
<nz-modal [(nzVisible)]="isVisible" nzTitle="抽奖活动设置" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()"
  nzWrapClassName="vertical-center-modal" [nzMaskClosable]="false" nzWidth="800">
  <div style="margin-bottom: 16px;" class="scrollbar my-modal">
    <nz-input-group nzAddOnBefore="抽奖页头标题(网页标题)">
      <input type="text" nz-input [(ngModel)]="doc.headtitle">
    </nz-input-group>
    <nz-input-group nzAddOnBefore="活动标题">
      <input type="text" nz-input [(ngModel)]="doc.title">
    </nz-input-group>
    <nz-input-group nzAddOnBefore="活动时间描述">
      <input type="text" nz-input [(ngModel)]="doc.gametime">
    </nz-input-group>
    <nz-input-group nzAddOnBefore="活动日期">
      <input type="text" nz-input [(ngModel)]="doc.time">
    </nz-input-group>
    <nz-input-group nzAddOnBefore="活动规则">
      <input type="text" nz-input [(ngModel)]="doc.gamerule">
    </nz-input-group>
    <nz-input-group nzAddOnBefore="抽奖次数">
      <input type="text" nz-input [(ngModel)]="doc.count">
    </nz-input-group>
    <nz-input-group nzAddOnBefore="活动开始时间">
      <nz-date-picker nzFormat="yyyy-MM-dd" [(ngModel)]="doc.starttime" nzPlaceHolder="开始日期">
      </nz-date-picker>
    </nz-input-group>
    <nz-input-group nzAddOnBefore="活动结束时间">
      <nz-date-picker nzFormat="yyyy-MM-dd" [(ngModel)]="doc.endtime" nzPlaceHolder="结束日期">
      </nz-date-picker>
    </nz-input-group>
    <div>
      <p><span>奖项设置：</span></p>
      <table *ngIf="doc.items">
        <thead>
          <tr>
            <th>奖项名称</th>
            <th>奖励描述</th>
            <th>赠送酒币数</th>
            <th>是否中奖</th>
          </tr>
        </thead>
        <tbody>
          <tr *ngFor="let item of doc.items;index as i">
            <td><input type="text" nz-input [(ngModel)]="item.name"></td>
            <td><input type="text" nz-input [(ngModel)]="item.remarks"></td>
            <td><input type="text" nz-input [(ngModel)]="item.conins"></td>
            <td>
              <nz-select style="width:100px;margin-right: 5px;" [(ngModel)]="item.win" nzPlaceHolder="是否中奖">
                <nz-option *ngFor="let a of winlist" [nzValue]="a.key" [nzLabel]="a.value"></nz-option>
              </nz-select>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>